list_each and babl_ticks()
authorØyvind Kolås <ok@src.gnome.org>
Sun, 18 Sep 2005 20:49:58 +0000 (20:49 +0000)
committerØyvind Kolås <ok@src.gnome.org>
Sun, 18 Sep 2005 20:49:58 +0000 (20:49 +0000)
ChangeLog
babl/babl-classes.h
babl/babl-util.c
babl/babl-util.h

index b97e751955804bc5d2ce27919269df0777ced1bc..39d594350182259d53aaa1a69dcc50846803e8a3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,53 @@
+2005-09-18  Øyvind Kolås  <pippin@gimp.org>
+
+       * babl/Makefile.am:
+       * babl/babl-classes.h:
+       * babl/babl-conversion.c: (each_babl_conversion_destroy),
+       (conversion_new), (create_name), (babl_conversion_new),
+       (babl_conversion_process), (test_create), (babl_conversion_error):
+       * babl/babl-core.c: (rgba_to_rgba), (babl_core_init):
+       * babl/babl-db.c: (babl_db_count):
+       * babl/babl-db.h:
+       * babl/babl-extension.c:
+       * babl/babl-fish.c: (match_conversion), (babl_conversion_find),
+       (babl_fish_db), (babl_fish), (babl_fish_process),
+       (each_babl_fish_destroy):
+       * babl/babl-format.c: (babl_format_new), (babl_formats_count),
+       (babl_format_with_model_as_type), (test_create),
+       (babl_format_loss):
+       * babl/babl-internal.c: (babl_process), (each_conversion),
+       (each_format), (gen_type_format_for_model),
+       (gen_formats_for_model), (babl_extension_post_load):
+       * babl/babl-internal.h:
+       * babl/babl-introspect.c: (conversion_introspect):
+       * babl/babl-model.c: (babl_model_new), (test_create),
+       (reference_format), (construct_double_format),
+       (babl_model_is_symmetric):
+       * babl/babl-sanity.c: (id_sanity):
+       * babl/babl-type.c: (babl_type_new), (r_interval), (test_init),
+       (double_vector_format), (babl_type_is_symmetric):
+       * babl/babl-util.c: (babl_list_each), (init_ticks), (babl_ticks):
+       * babl/babl-util.h:
+       * babl/base/model-cmyk.c: (rgb_to_cmyk), (cmyk_to_rgb),
+       (conversions), (formats):
+       * babl/base/model-gray.c: (rgba_to_graya), (rgba_to_gray),
+       (graya_to_rgba), (gray_to_rgba), (conversions):
+       * babl/base/model-rgb.c: (formats):
+       * babl/base/model-ycbcr.c: (rgba_to_ycbcra), (rgba_to_ycbcr),
+       (ycbcra_to_rgba), (ycbcr_to_rgba), (conversions), (formats):
+       * docs/Makefile.am:
+       * docs/index-static.html.in:
+       * extensions/CIE-Lab.c: (rgba_to_lab), (lab_to_rgba),
+       (rgba_to_laba), (laba_to_rgba), (conversions):
+       * extensions/Makefile.in:
+       * extensions/naive-CMYK.c: (init), (rgba_to_cmyk), (cmyk_to_rgba):
+       * tests/Makefile.am:
+       * tests/babl-html-dump.c: (main):
+       * tests/conversions.c: (each_conversion), (main):
+       * tests/formats.c: (format_check), (main):
+       * tests/models.c: (model_check), (main):
+       * tests/types.c: (type_check), (main):
+
 2005-09-18  Øyvind Kolås  <pippin@gimp.org>
 
        * babl/babl.c: (babl_init),
index d6adbb9f166eab6b1464523db12a032944ac41e0..007ba97105b5bb231ebdcf710428b4f53baa8036 100644 (file)
@@ -43,20 +43,6 @@ typedef long (*BablFuncPlanar)    (int    src_bands,
                                    int    dst_pitch[],
                                    long   n);
 
-#if 0
-typedef long (*BablFuncPlanarBit) (int    src_bands,
-                                   void  *src[],
-                                   int    src_bit[],
-                                   int    src_pitch[],
-                                   int    src_bit_pitch[],
-                                   int    dst_bands,
-                                   void  *dst[],
-                                   int    dst_bit[],
-                                   int    dst_pitch[],
-                                   int    dst_bit_pitch[],
-                                   long   n);
-#endif
-
 /* magic number used at the start of all babl objects, used to do
  * differentiation in polymorphic functions. (as well as manual
  * type check assertions).
@@ -81,6 +67,7 @@ typedef enum {
   BABL_FISH,
   BABL_FISH_REFERENCE,
   BABL_FISH_SIMPLE,
+  BABL_FISH_PATH,
   BABL_IMAGE,
 
   BABL_EXTENSION,
@@ -106,7 +93,7 @@ BablConversion {
   BablInstance           instance;
   union Babl            *source;
   union Babl            *destination;
-  int                    time_cost;
+  int                    cost;
   double                 error;
   union
     {
@@ -202,6 +189,13 @@ typedef struct
   int            *stride;
 } BablImage;
 
+/* BablFish base class, the user of babl is just requesting a
+ * conversion, after that an appropriate species of fish is
+ * constructed to handle the request.
+ * 
+ * TODO:
+ *   * implement 
+ */
 typedef struct
 {
   BablInstance    instance;
@@ -211,6 +205,37 @@ typedef struct
   long  pixels;
 } BablFish;
 
+
+
+/* BablFishSimple is the simplest type of fish, wrapping a single
+ * conversion function, (note this might not be the optimal chosen
+ * conversion even if it exists)
+ */
+typedef struct
+{
+  BablFish         fish;
+  BablConversion  *conversion;
+} BablFishSimple;
+
+
+
+/* BablFishPath is a combination of registered conversions, both
+ * from the reference types / model conversions, and optimized paths.
+ *
+ * This is the most advanced scheduled species of fish, some future
+ * version of babl might even be evovling combined fishes in a background
+ * thread, based on profiled usage. For this to work in a future version
+ * transmogrification between the fish classes would be used.
+ */
+typedef struct
+{
+  BablFish         fish;
+  double           cost;
+  double           loss;
+  BablConversion  *conversion[BABL_MAX_PATH_LENGTH];
+  int              conversions;
+} BablFishPath;
+
 /* BablFishReference on the double versions of conversions
  * that are required to exist for maximum sanity.
  *
@@ -222,21 +247,19 @@ typedef struct
  * implementation is meant to be kept as small as possible wrt logic.
  *
  * One of the contributions that would be welcome are new fish factories.
+ *
+ * TODO:
+ *   * cache the looked up conversions, removing all overhead but the
+ *     actual conversions.
+ *   * make optimal use of a single allocation containing enough space
+ *     for the maximum amount of memory needed in to adjecant buffers
+ *     at any time.
  */
 typedef struct
 {
   BablFish         fish;
 } BablFishReference;
 
-/* BablFishSimple is the simplest type of fish, wrapping a single
- * conversion function
- */
-typedef struct
-{
-  BablFish         fish;
-  BablConversion  *conversion;
-} BablFishSimple;
-
 typedef struct
 {
   BablInstance   instance;               /* path to .so / .dll is stored in instance name */
@@ -256,8 +279,9 @@ typedef union
   BablConversion    conversion;
   BablImage         image;
   BablFish          fish;
-  BablFishReference reference_fish;
+  BablFishReference fish_reference;
   BablFishSimple    fish_simple;
+  BablFishPath      fish_path;
   BablExtension     extension;
 } Babl;
 
index 8df5839a482e720cd7e0d8f61df367322da25ca0..182f5e383b50276f63ca16c97e5f84adee4e21ba 100644 (file)
@@ -60,3 +60,43 @@ babl_add_ptr_to_list (void ***list,
   (*list)[orig_len+1]=NULL;
 }
 
+void
+babl_list_each (void             **list,
+                BablEachFunction   each_fun,
+                void              *user_data)
+{
+  int i;
+  if (!list)
+    return;
+  for (i=0; i < list_length (list); i++)
+    {
+      if (each_fun ((Babl*) list[i], user_data))
+         break;
+    }
+}
+
+#include <sys/time.h>
+#include <time.h>
+
+static struct timeval start_time;
+static struct timeval measure_time;
+
+#define msecs(time) ((time.tv_sec-start_time.tv_sec)*1000 + time.tv_usec/1000)
+
+static void
+init_ticks (void)
+{
+  static int done=0;
+  if (done)
+    return;
+  done=1;
+  gettimeofday (&start_time, NULL);
+}
+
+unsigned int
+babl_ticks (void)
+{
+  init_ticks ();
+  gettimeofday (&measure_time, NULL);
+  return msecs(measure_time) - msecs(start_time);
+}
index 97b0816ff28def9837640cf18720b41911adec0f..9fa11763022a8c6fd366f7348562f142c920c49e 100644 (file)
 void   babl_add_ptr_to_list (void       ***list,
                              void         *new);
 
+void
+babl_list_each (void             **list,
+                BablEachFunction   each_fun,
+                void              *user_data);
+
+unsigned int    babl_ticks (void);
 #endif